package com.gaussian.property.admin.module.biz.controller.openapi;

import com.songqi.common.core.domain.R;
import com.songqi.common.core.exception.CustomException;
import com.songqi.common.core.utils.sign.Md5Utils;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: songqi(13776346982)
 * @date: 2023/3/13 20:05
 */
@RestController
@RequestMapping("/api/")
@Api(tags = "对外开放接口")
public class OpenApiController {



    @Value("${application.http-sign-secret}")
    private String secret;

    @GetMapping("test")
    public R<Void> test(@RequestHeader("nonce") String nonce,
                        @RequestHeader("timeStamp") String timeStamp,
                        @RequestHeader("sign")String sign) {
        String hashSign = Md5Utils.hash(timeStamp + nonce + secret);
        if(!hashSign.equals(sign)){
            throw new CustomException("sign参数错误");
        }
        //TODO: 这里调用业务处理逻辑
        return R.success();
    }
}
